#ifndef _T_STATIC_ARRAY_H
#define _T_STATIC_ARRAY_H


//----------------------------------------------
template <typename T, size_t CAPACITY>
class TStaticArray
{
public:
	TStaticArray()					{}

	size_t		capacity		() const			{ return CAPACITY; }
	void		setOnAll		(const T& oVal)		{ for(int i=0; i<m_size; i++) m_elements[i] = oVal; }
	const T&	operator[]		(size_t szEl) const	{ assert(szEl < CAPACITY ); return m_elements[szEl]; }
	T&			operator[]		(size_t szEl)		{ assert(szEl < CAPACITY ); return m_elements[szEl]; }
protected:
	T			m_elements[CAPACITY];
};

//----------------------------------------------
template <typename T, size_t CAPACITY>
class TStaticStack : public TStaticArray<T, CAPACITY>
{
public:
	TStaticStack() : m_size(0)		{}

	size_t		size		() const			{ return m_size; }
	int			push		(const T& oVal)
	{
		int iIndex = -1;
		if (m_size < CAPACITY)
		{
			iIndex = m_size;
			m_elements[iIndex] = oVal;
			++m_size;
		}

		return iIndex;
	}
	T			pop			()
	{
		assert(m_size > 0);
		--m_size;
		return m_elements[m_size];
	}
	bool		isEmpty		() const			{ return m_size == 0; }
	bool		isFull		() const			{ return m_size == CAPACITY; }
	void		clear		()					{ m_size = 0; }
protected:
	size_t		m_size;
};

#endif